#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
long double t;
long double n,m,L,V;
long double d,v,a;
long double p[N];
int z,y,ans;
struct node{
	long double l,r;
}over[N];
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>t;
	while(t--){
	cin>>n>>m>>L>>V;
	for(int i=1;i<=n;i++){
		cin>>d>>v>>a;
		a*=2;
		if(a==0){
			if(v>V){
				over[i].l=d;
				over[i].r=L;
			}
		}
		if(a>0){
			over[i].l=(V+v)*(V-v)/a+d;
			over[i].l=floor(over[i].l)+1;
			if(over[i].l>=L){
				over[i].l=0;
				over[i].r=0;
			} 
			else over[i].r=L;
		}
		if(a<0){
			if(v<V){
				over[i].l=0;
				over[i].r=0;
			}
			if(v==V){
				over[i].l=d;
				over[i].r=d;
			}
			else{
				over[i].l=d;
				over[i].r=(V+v)*(V-v)/a+d;
				over[i].r=ceil(over[i].r)-1;
				if(over[i].r>L) over[i].r=L;
			}
		}
	}
	for(int i=1;i<=m;i++) cin>>p[i];
	for(int i=1;i<=n;i++){
		if(over[i].l&&over[i].r){
			z=0;y=0;
			for(int j=1;j<=m;j++){
				if(!z&&over[i].l<=p[j]) over[i].l=p[j],z++;
				if(over[i].r>=p[j]) y=j;
			}
			over[i].r=p[y];
			if(over[i].r<over[i].l) over[i].l=0,over[i].r=0;
		}
	}
	for(int i=1;i<=n;i++)
		if(over[i].l&&over[i].r) ans++;
	cout<<ans<<" ";
	ans=0;
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			if(!over[i].r||!over[j].r) continue;
			if(over[i].l>over[j].r&&over[i].r<over[j].l) continue;
			if(over[i].l>=over[j].l&&over[i].r<=over[j].r) over[j].l=0,over[j].r=0;
			else if(over[i].l<over[j].l&&over[i].r>over[j].r) over[i].l=0,over[i].r=0;
			else if(over[i].l<=over[j].r&&over[i].l>=over[j].l) over[i].r=over[j].r,over[j].l=over[j].r=0;
			else if(over[j].l<=over[i].r&&over[j].l>=over[i].l) over[i].l=over[j].l,over[j].l=over[j].r=0;
		}
	}
	for(int i=1;i<=n;i++)
		if(over[i].l&&over[i].r) ans++;
	cout<<m-ans<<endl;
	for(int i=1;i<=n;i++) over[i].l=over[i].r=0;
	for(int i=1;i<=m;i++) p[i]=0;
	ans=0;z=0;y=0;
	}
    return 0;
}
